package com.study.model.vo;

import java.io.Serializable;
import java.util.List;

/**
 * 统一响应对象
 */
public class MyResult implements Serializable {
	private Integer code;
	private String msg;
	private List<?> data;
	private Object obj;

	/**
	 * 成功
	 */
	public static MyResult SUCCESS = new MyResult();

	/**
	 * 失败
	 * 
	 * @param message
	 * @return
	 */
	public static MyResult FAILURE(String message) {
		return new MyResult(message);
	}

	/**
	 * 成功并携带集合数据
	 * 
	 * @param list
	 * @return
	 */
	public static MyResult SUCCESS_DATA(List<?> list) {
		return new MyResult(list);
	}

	/**
	 * 成功并携带单个对象数据
	 * 
	 * @param obj
	 * @return
	 */
	public static MyResult SUCCESS_Object(Object obj) {
		return new MyResult(obj);
	}

	public MyResult(List<?> list) {
		this.code = 1;
		setData(list);
	}

	public MyResult(Object obj) {
		this.code = 1;
		setObj(obj);
	}

	public void setObj(Object obj) {
		this.obj = obj;
	}

	public Object getObj() {
		return obj;
	}

	public MyResult() {
		this.code = 1;
	}

	public MyResult(String msg) {
		this.code = 0;
		this.msg = msg;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public List<?> getData() {
		return data;
	}

	public void setData(List<?> data) {
		this.data = data;
	}

}
